package cn.caplike.demo.spring.bean.lifecycle.custom.init.and.destroy.method;

/**
 * While declaring bean in XML configuration,
 * you can specify the init-method and destroy-method attributes in the tag.
 * <p>
 * Both the attributes specify custom methods in the bean class.
 *
 * @author LiKe
 * @version 1.0.0
 * @date 2020-03-31 17:41
 */
public class BookCustomBean {

    private String bookName;

    public BookCustomBean() {
        System.out.println("Constructor of BookCustomBean bean is called !! ");
    }

    public BookCustomBean(String bookName) {
        this.bookName = bookName;
    }

    public void customDestroy() throws Exception {
        System.out.println("Custom destroy method of BookCustomBean called !! ");
    }

    public void customInit() throws Exception {
        System.out.println("Custom Init method of BookCustomBean called !! ");
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookName='" + bookName + '\'' +
                '}';
    }

}
